//https://www.luogu.com.cn/problem/P2347

#include<iostream>
#include<ranges>
#include<vector>
#include<set>
#include<array>
#include<numeric>
using namespace std;
namespace rg=ranges;
namespace vi=rg::views;
using record = std::array<int,6>;
vector<vector<record>> V_S_REC;
record Accounts={1,2,3,5,10,20};
auto Value(const record& x){return inner_product(x.begin(),x.end(),Accounts.begin(),0);}
// struct record{
// 	int a,b,c,d,e,f;
// 	int value(){return a*1+b*2+c*3+d*5+e*10+f*20;}
// };


int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	record Initial{ a,b,c,d,e,f };
	record partial;
	//const int MAX=Value(Initial);
	partial[0] = a + 1;
	auto add=[](int before,int now,int account){
		return before <account?(now+1)*before: now*account + before;
	};

	for(int i = 1;i < 6;++i) {
		partial[i] = partial[i - 1] < Accounts[i] ? ((Initial[i] + 1) * partial[i - 1]) : (Initial[i] * Accounts[i] + partial[i - 1]);
	}
	cout << "Total=" << partial[5] - 1;
}